package com.timebank.volunteer.controller;

import com.timebank.common.core.web.controller.BaseController;
import com.timebank.common.core.web.page.TableDataInfo;
import com.timebank.common.core.web.pojo.AjaxResult;
import com.timebank.common.security.annotation.RequiresLogin;
import com.timebank.volunteer.pojo.vo.VolunteerSignListVO;
import com.timebank.volunteer.service.VolunteerSignListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 志愿服务 签到名单
 * @author shiliuyinzhen
 */
@RestController
@RequestMapping("/signList")
@Api(tags = "志愿服务签到名单相关接口")
public class VolunteerSignListController extends BaseController {

    @Autowired
    private VolunteerSignListService volunteerSignListService;

    /**
     * 根据志愿服务id获取签到名单
     * @param volunteerId
     * @return
     */
    @RequiresLogin
    @GetMapping("/list/{volunteerId}")
    @ApiOperation("根据志愿服务id获取签到名单")
    public TableDataInfo getSignListByVolunteerId(@PathVariable("volunteerId") Long volunteerId){
        startPage();
        List<VolunteerSignListVO> list = volunteerSignListService.getSignListByVolunteerId(volunteerId);
        return getDataTable(list);
    }

    /**
     * 获取志愿者签到记录
     * @param volunteerId
     * @param userId
     * @return
     */
    @RequiresLogin
    @GetMapping("/signLog/{volunteerId}")
    @ApiOperation("获取志愿者签到记录")
    public AjaxResult getSignListByVolunteerIdAndUserId(
            @PathVariable("volunteerId") Long volunteerId,@RequestParam("userId") Long userId)
    {
        List<VolunteerSignListVO> list =
                volunteerSignListService.getSignListByVolunteerIdAndUserId(volunteerId,userId);
        return AjaxResult.success(list);
    }
}
